#ifndef BASE_ROOM_H
#define BASE_ROOM_H
#include <vector>
#include <set>
#include <map>
#include <string>
class BasePlayer;
class BaseDesk;
class BaseGameImpl;
struct BaseProtoRoomState;
class BaseRoom
{
public:
	virtual void onPlayerMessage(BasePlayer* player, void* data, int len) {}
	virtual void onPlayerJoin(BasePlayer* player) {}
	virtual void onPlayerLeave(BasePlayer* player) {}
	virtual void onPlayerRequestJoinDesk(BasePlayer* player, int deskId, int chairId);
	BaseRoom(void);
	~BaseRoom(void);

public:
	void generateRoomStatusMsg(BaseProtoRoomState* roomStatus);
protected:
	bool assignDesk(BaseDesk* desk, int chairId, BasePlayer* player);
private:
	friend class BaseGameImpl;
	void procPlayerJoin(BasePlayer* player);
	void procPlayerLeave(BasePlayer* player);
	void procPlayerCreateFriend(BasePlayer* player);
	void procPlayerJoinFriend(BasePlayer* player, const std::string& deskCode);
private:	
	void addDesk(BaseDesk* desk);
	BaseDesk* getEmptyDesk();
	std::string generateDeskCode();
	friend BaseDesk;
protected:
	std::set<BasePlayer*> m_setPlayers;
	std::vector<BaseDesk*> m_vecDesks;
	std::map<std::string, BaseDesk*> m_mapFriendDesks;
	int m_roomId;
};
#endif
